
var arr = ['小明'];
for (var i = 0; i < arr.length; i++) {
    if (i==0) {
        var num1 =['欢迎'+arr[i]];
        
    }else if(i<arr.length-1)
    {
        for (var j = 1; j < arr.length-1; j++) {
           
            var num2 = [arr[arr.length-2]]
            for (b = 1; b <= arr.length-3; b++) {
               
                num2 = num2+','+arr[i-b]
            }
        }
        
    }else
    {
        var num3 = ['和'+arr[i]+'同学!'];
    }
}
    


    console.log(num1+','+num2+num3);


   console.log(arr.length)